package com.jobs.TreeHashDemo;

import lombok.*;

/**
 * the class of jdk8_stream_demo
 *
 * <p>
 * .
 *
 * @author little_lunatic
 * @date 2023-07-07
 */
//@Data
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Student implements Comparable<Student>{

    private int id;

    private int age;

    private String name;

    private String sex;

    private boolean option;

    @Override
    public int compareTo(Student student) {
        return Integer.compare(this.age, student.age);
    }

    @Override
    public int hashCode() {
        System.out.println("hashCode:"+this.id+this.name+this.age);
        return this.age+this.name.hashCode()+this.sex.hashCode()+(this.option?1:0);
    }

    @Override
    public boolean equals(Object obj) {
        System.out.println("equals:"+this.id+this.name+this.age);

        if (obj instanceof Student) {
            Student student = (Student) obj;
            System.out.println("equals-----:"+student.id+student.name+student.age);
            return (this.age == student.age)&&(this.name.equals(student.name))&&(this.sex.equals(student.sex))&&this.option==student.option&&(this.id==student.id);
        }
        return false;
    }
}
